<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Travian辅助</title>
	<meta name="keywords" content="淮阳网站建设|周口网站建设">
	<meta name="description" content="淮阳网站建设|周口网站建设">
    <meta content="telephone=no" name="format-detection">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="renderer" content="webkit"><!--双引擎浏览器默认webkit打开-->
	<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no">
	<meta name="full-screen" content="yes">
	<link rel="stylesheet" href="__PUBLIC__/css/uikit1.css">
	<script type="text/javascript" src="__PUBLIC__/js/jquery.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/uikit.js"></script>
	
	<style>
	body{ padding:10px;}
	.active{color:#e4392a; border-bottom:3px solid #e4392a;}
	#my-id{ height:680px; line-height:1.8em;}
	#msg1,#msg1{ width:50%}
	#my-id li{word-wrap:break-word; word-break:normal; }
	</style>
</head>
<body>

<input id="userinfo" type="hidden" data-uid='{$me.id}' data-name='{$me.user}' data-server='{$me.server}'>
账户：
{volist name="user" id="v"}
<span><a href="{:url('travian/index/index')}/uid/{$v.id}">{$v.user} @ {$v.server}</a></span>
{/volist}
<input name="settimeout" type="text" class="uk-margin-small-top" value="15" placeholder="循环检测时间（秒）">　 <span class="link" data-link="dorf1.php">村外</span>　<span class="link" data-link="dorf2.php">村内</span>　<span class="link" data-link="dorf1.php">兵营</span>　<span class="link" data-link="dorf1.php">马厩</span> 
<div class="uk-grid">
<div class="uk-width-1-1">
村庄：
<div class="uk-grid">
<div id="task_grid">

<ul class="uk-subnav uk-subnav-pill" data-uk-switcher="{connect:'#my-id'}" id="tab1">
{volist name="list" id="v"}
<li><a href="#">{$v.vid}</a></li>
{/volist}
</ul>

<!-- 这是内容项目的容器 -->
<ul id="my-id" class="uk-switcher">
{volist name="list" id="v"}
<table width="100%" border="0">
  <tr>
    <td colspan="2">
<li data-vid="{$v.vid}">
{volist name="v['task']" id="v2"}
<button class="uk-button uk-button-small" type="button" data-tid="{$v2.id}" data-onclick="addtask({$v.vid},{$v2.build})" onclick="deltask({$v2.id})">{$v2.title}</button> 
{/volist}
<div data-tid="{$v.task_b.id}">兵营：{$v.task_b.build} 兵种：{$v.task_b.t} 兵数：{$v.task_b.ts} 马厩：{$v.task_b.build2} 马种：{$v.task_b.t} 马数：{$v.task_b.ts2}</div> 
</li>

</td>
  </tr>
  <tr>
    <td id="msg1">
	msg1
    </td>
    <td id="msg2">
	msg2
	</td>
  </tr>
</table>

{/volist}
</ul>

</div>
</div>	
<div class="uk-panel uk-panel-box"><button class="uk-button uk-button-primary" type="button" onClick="read_viliage()">读取村庄</button> 
<button class="uk-button uk-button-primary" type="button" id="start_task" onClick="startBot();dis()">开始任务</button> 
<button class="uk-button uk-button-primary" type="button" id="start_task">停止任务</button>
<button class="uk-button uk-button-primary" type="button" id="test1" >测试按钮</button>
</div></div>
</div>
</body>
<script>
var uid = $('#userinfo').attr('data-uid');
var server = $("#userinfo").attr('data-server'); 
var settimeout;
$('.link').click(function(){
	var linka = $(this).attr('data-link');
	window.open(server+linka);    
	});

function dis(){
	$('#start_task').attr("disabled", true);
	}

function timeb(timeb){
  times = timeb.split(':'); //times倒计时数组（小时，分钟，秒）
  timesec = (times[0]*3600+times[1]*60+times[2]*1); //timesec是倒计时 毫秒
  return timesec;
}

function read_viliage(){
	var vid = $('#tab1 .uk-active a').text();
    $.get(server +"dorf1.php?newdid="+vid+'&m='+Math.random(),function(dorf1){
        if($(dorf1).find(".loginTable").length>0){
            $("#message1").html("你还没有登陆游戏，请先登录！");
            $("#msg1").html("你还没有登陆游戏，请先登录！");
        }else{
            var dorfa = [];
            var dorfb = [];
            $(dorf1).find("area").each(function()
            {
                dorfa.push($(this).attr("title"));
                dorfb.push($(this).attr("href"));
            });
  //var dorfa = $(dorf1).find("#logo").html();
  //alert("fff");
            var dorf1html="";
            for(i=0;i<18;i++){
                var jinum;
                var buildid;
                var n1=dorfa[i].indexOf("<div style='color:#FFF'>")+24;　
                var n2=dorfa[i].indexOf('</div>');　　　
                str=dorfa[i].substring(n1,n2);
				str = str.replace('Bosque', "伐木场");
				str = str.replace('Poço de Barro', "黏土矿");
				str = str.replace('Mina de Ferro', "铁矿场");
				str = str.replace('Campo de Cereal', "农场");
				str = str.replace('nível', "等级");
				var n11=str.indexOf("<b>")+3;　
				var n12=str.indexOf("</b>");　
				title = str.substring(n11,n12);
  //ji = dorfa[i].substring(n2-3,n2);
                buildid = i+1;
                jinum='<button class="uk-button uk-button-primary uk-button-small" type="button" onclick=\"addtask(\''+vid+'\',\''+buildid+'\',\''+title+'\');\"> + </button>';
                dorf1html+=str+" "+jinum+"<br/>";
            }
            $("#msg1").html(dorf1html);
		}
	});
	
	$.get(server +"dorf2.php?newdid="+vid+'&m='+Math.random(),function(dorf2){
        if($(dorf2).find(".loginTable").length>0){
            $("#message1").html("你还没有登陆游戏，请先登录！");
            $("#msg1").html("你还没有登陆游戏，请先登录！");
        }else{
            var dorfa = [];
            var dorfb = [];
            $(dorf2).find("area").each(function()
            {
                dorfa.push($(this).attr("title"));
                dorfb.push($(this).attr("href"));
            });
  //var dorfa = $(dorf1).find("#logo").html();
  //alert("fff");
            var dorf2html="";
            for(i=0;i<22;i++){
                var jinum;
                var buildid;var title;
                var n1=dorfa[i].indexOf("<div style='color:#FFF'>")+24;　
                var n2=dorfa[i].indexOf('</div>');　　　
                str=dorfa[i].substring(n1,n2);
				str = str.replace('nível', "等级");
				str = str.replace('Zona para construção', "空地");
				str = str.replace('Edifício Principal', "中心大楼");
				str = str.replace('Celeiro', "粮仓");
				str = str.replace('Armazém', "仓库");
				str = str.replace('Ponto de Reunião Militar', "集结点");
				str = str.replace('Palisade', "城墙");
				str = str.replace('Quartel', "兵营");
				str = str.replace('Academia', "研发所");
				str = str.replace('Cavalaria', "马厩");
				str = str.replace('Smithy', "兵工厂");
				str = str.replace('Quartel', "市场");
				str = str.replace('Residência', "行宫");
				str = str.replace('Grain Mill', "磨坊");
				str = str.replace('Sawmill', "木材厂");
				str = str.replace('Brickworks', "砖块厂");
				str = str.replace('Iron Foundry', "铸造厂");
				str = str.replace('Palácio', "皇宫");
				str = str.replace('Horse Drinking Pool', "饮马槽");
				str = str.replace('Tavern', "英雄园");
				str = str.replace('StoneMason', "石匠铺");
				str = str.replace('Oficina', "工场");
				var n11=str.indexOf("<b>")+3;　
				var n12=str.indexOf("</b>");　
				title = str.substring(n11,n12);
                buildid = i+19;
				if(str != '空地'){jinum='<button class="uk-button uk-button-primary uk-button-small" type="button" onclick=\"addtask(\''+vid+'\',\''+buildid+'\',\''+title+'\');\"> + </button>';}else{jinum = 'X';};
                
                dorf2html+=str+" "+jinum+"<br/>";
            }
            $("#msg2").html(dorf2html);
		}
	});
}

function deltask(id){
    var btn = $(this);
	$.get("{:url('del_build')}/id/"+id,function(res){
	    if(res.res == 1){
		    //btn.hide();
			$('[data-tid="'+id+'"]').remove();
			//$('#my-id').append('btn------666----------------');
		}else{
		    alert('移除任务失败');
		}
	});
}

function addtask(vid,bid,title){
    //var arr = str.split('|');
	//var title = $(this).parent().find('b').text();
	//var title = $(this).parent().find('b').text();
	var obj = {};
	obj['title'] = title;
	$.get("{:url('add_build')}/vid/"+vid+"/bid/"+bid,obj,function(res){
	    if(res.res == 1){
		    var btn = ' <button class="uk-button uk-button-small" type="button" data-tid="'+res.id+'" data-onclick="addtask('+res.id+','+bid+')" onclick="deltask('+res.id+')">'+title+'</button>';
		    $('li[data-vid="'+vid+'"]').append(btn);
			//$('#my-id').append('btn------666----------------');
		}else{
		    alert('添加任务失败');
		}
	});
}

//造兵任务检测
function startBot2(){
    $.get("{:url('get_task2')}/uid/{$uid}",function(data){
		if($(data).length>0){
	    $.each(data,function(i,son){
			//alert(i);
		    var arr = [];
			arr[0] = son.id;
			arr[1] = son.vid;
			arr[2] = son.ft;
			arr[3] = son.build;
			arr[4] = son.t;
			arr[5] = son.ts;
			arr[6] = son.build2;
			arr[7] = son.t2;
			arr[8] = son.ts2;
			arr[9] = son.times;
			//arr[8] = son.start_time;
			var str = arr.toString();
			setTimeout('zao2("'+str+'")',500);
		});
		}else{
			//startBot3();
		}
		setTimeout('startBot3()',1000);
	});
}

//开始造兵
function zao2(str){
			var url = server + "build.php";
			var arr = str.split(",");
		    var  id    = arr[0];
		    var vid    = arr[1];
			var ft     = arr[2];
			var build  = arr[3];
			var t      = arr[4];
			var ts     = arr[5];
			/*
			var build2 = arr[6];
			var t2     = arr[7];
			var ts2    = arr[8];
			*/
			var obj = {};
			obj['id'] = build;
			obj['ft'] = ft;
			obj[t] = ts;
			if(ts*1>0){
			$.ajax({
			    url: url,
			    type: 'post',
			    cache:false, 
			    data: obj,
			    dataType: 'html',
			    success: function(data1) {
			}
			});
			}
	setTimeout('zao2b("'+str+'")',1000);		
}

//开始造马（如果有）
function zao2b(str){
			var url = server + "build.php";
			var arr = str.split(",");
		    var  id    = arr[0];
		    var vid    = arr[1];
			var ft     = arr[2];
			var build2 = arr[6];
			var t2     = arr[7];
			var ts2    = arr[8];
			var times  = arr[9];
			
			var obj = {};
			obj['id'] = build2;
			obj['ft'] = ft;
			obj[t2] = ts2;
			if(ts2*1>0){
			$.ajax({
			    url: url,
			    type: 'post',
			    cache:false, 
			    data: obj,
			    dataType: 'html',
			    success: function(data1) {
			}
			});
			}
			$.get("{:url('set_task2')}/id/"+id+"/times/"+times,function(data){});
		//setTimeout('startBot3()',1000);	
}

//抢夺任务检测
function startBot3(){
    $.ajax({
			        url: "{:url('get_task3')}/uid/{$uid}",
			        type: 'get',
			        cache:false, 
					async : false,//
			        data: '',
			        dataType: 'json',
			        success: function(data) {
        //$.get("{:url('get_task3')}/uid/{$uid}",function(data){
		//如果有目标就是1
		//var status = 0;
		//var iii = 0;var status;
		//if($(data).length>0){
	    $.each(data,function(i,son){
		/*
		iii++;
		if(iii>=$(data).length){
		    status = 0;
		}
		*/
		//历编每个目标
			var arr = [];
			arr[0] = son.id;
			arr[1] = son.vid;
			arr[2] = son.x;
			arr[3] = son.y;
			arr[4] = son.t;
			arr[5] = son.times;
			//arr[6] = status;
			//arr[8] = son.start_time;
			var str = arr.toString();
			setTimeout('zao3("'+str+'")',800);
		});
		
		//}else{
		    //sleep_b();
		//}
		}
	});
	sleep_b();
}

//开始攻击
function zao3(str){
	            var arr1   = str.split(",");
				var  id    = arr1[0];
	    	    var vid    = arr1[1];
	    	    var x      = arr1[2];
	    	    var y      = arr1[3];
	    	    var t      = arr1[4];
	    	    var times  = arr1[5];
				//var status = arr1[6];
				
				var arr = t.split("|");
				var obj = {};var obj2 = {};
				if(arr[0]>0){obj['t1']=arr[0];obj2['t1']=arr[0];}
				if(arr[1]>0){obj['t2']=arr[1];obj2['t2']=arr[1];}
				if(arr[2]>0){obj['t3']=arr[2];obj2['t3']=arr[2];}
				if(arr[3]>0){obj['t4']=arr[3];obj2['t4']=arr[3];}
				if(arr[4]>0){obj['t5']=arr[4];obj2['t5']=arr[4];}
				if(arr[5]>0){obj['t6']=arr[5];obj2['t6']=arr[5];}
				if(arr[6]>0){obj['t7']=arr[6];obj2['t7']=arr[6];}
				if(arr[7]>0){obj['t8']=arr[7];obj2['t8']=arr[7];}
				if(arr[8]>0){obj['t9']=arr[8];obj2['t9']=arr[8];}
				if(arr[9]>0){obj['t10']=arr[9];obj2['t10']=arr[9];}
				if(arr[10]>0){obj['t11']=arr[10];obj2['t11']=arr[10];}
				obj['x'] = x;
				obj['y'] = y;
				obj['c'] = 4;
				obj['s1'] = 'ok';
				$.ajax({
			        url: server +"a2b.php"+"?newdid="+vid,
			        type: 'post',
			        cache:false, 
					async : false,//
			        data: obj,
			        dataType: 'html',
			        success: function(a2b) {
					if($(a2b).find('.troop_details').length>0){
					    //成功到发兵确认页面
						obj2['id'] = '39';
						obj2['timestamp'] = $(a2b).find('[name="timestamp"]').val();
						obj2['timestamp_checksum'] = $(a2b).find('[name="timestamp_checksum"]').val();
						obj2['ckey'] = $(a2b).find('[name="ckey"]').val();
						obj2['a'] = $(a2b).find('[name="a"]').val();
						obj2['c'] = 3;
						obj2['s1'] = 'ok';
						$.ajax({
						    url: server +"a2b.php"+"?newdid="+vid,
						    type: 'post',
						    cache:false, 
							async : false,//
						    data: obj2,
						    dataType: 'html',
						    success: function(a2b2) {
						        if($(a2b2).find('img.g16').length>0){
						        //发兵成功
						            $.get("{:url('set_task3')}/id/"+id+"/times/"+times,function(data){
									    
									});
								}
						    }
						});
					}
					}
			    });
		/*
		if(status = 0){
		    sleep_b();
		}
		*/
}

//建筑任务检测
function startBot(){
    $.get("{:url('get_task')}/uid/{$uid}",function(data){
		//if($(data).length>0){
	    $.each(data,function(i,son){
			//alert(i);
		    var arr = [];
			arr[0] = son.id;
			arr[1] = son.vid;
			arr[2] = son.build;
			arr[3] = son.level;
			arr[4] = '';
			var resource = [];
			var href;
			var build;
			resource[0] = "<div style='color:\\#FFF'><b>Bosque</b>";
			resource[1] = "<div style='color:\\#FFF'><b>Poço de Barro</b>";
			resource[2] = "<div style='color:\\#FFF'><b>Mina de Ferro</b>";
			resource[3] = "<div style='color:\\#FFF'><b>Campo de Cereal</b>";
			//arr[3] = 'yes';//yes代表需要建造。
			
			//如果level字段大于0，就是按库存P田，到等级level级。
			if(arr[3]*1>0){
			    var vid = $('#tab1 .uk-active a').text();
				$.ajax({
				    url: server +"dorf1.php?newdid="+vid+'&m='+Math.random(),
				    type: 'get',
				    cache:false, 
				    async : false,//
				    data: '',
				    dataType: 'html',
				    success: function(dorf1) {
					    //先看库存
						var arr_num = [];var num;
						$(dorf1).find('.stockBarButton .value').each(function(){
						    num = $(this).text()*1;
					        arr_num.push(num);
						});
						//第几个元素的资源库存最少，然后n就是这个上面定义的resource字符串
						var n = resource[arr_num.indexOf(Math.min.apply(Math, arr_num))];
						var arr_num2 = [];
						$(dorf1).find('map area[title*="'+n+'"]').each(function(){
						    var str = $(this).attr('title');
						    var n11=str.indexOf("</b> nível ")+11;　
						    var n12=str.indexOf("</div>");　
						    var num2 = str.substring(n11,n12)*1;
						    arr_num2.push(num2);
						});
						//历编所有资源田等级   暂时没使用
						//如果使用就把下面的  if(Math.min.apply(Math, arr_num2)<son.level*1){ 其中的arr_num2改为arr_num3
						var arr_num3 = [];
						$(dorf1).find('map area').each(function(){
						    var str = $(this).attr('title');
						    var n11=str.indexOf("</b> nível ")+11;　
						    var n12=str.indexOf("</div>");　
						    var num3 = str.substring(n11,n12)*1;
						    arr_num3.push(num3);
						});
						//历编所有资源田等级 end
						if(Math.min.apply(Math, arr_num2)<son.level*1){
						//如果最小的指定类型田小于等于设定目标等级，
						    var n2 = arr_num2.indexOf(Math.min.apply(Math, arr_num2));
						    href = $(dorf1).find('map area[title*="'+n+'"]').eq(n2).attr('href');
							var arrr = href.split('=');
							build = arrr[1];
						}else{
							//否则跳过，并删除任务
							//nono2 是直接删除任务
							arr[4] = 'nono2';
						}
					}
				});
				arr[2] = build;
				//nono是不删任务，只更新下次时间
				arr[4] = 'nono';
				var str = arr.toString();
				setTimeout('zao("'+str+'")',500);
			}else{
			var str = arr.toString();
			setTimeout('zao("'+str+'")',500);
			}
		});
		//}else{
			
		//}
		setTimeout('startBot2()',1000);
	});
}

function sleep_a(){
	setTimeout('startBot2()',1000);
}

function sleep_b(){
    settimeout = $('[name="settimeout"]').val();
	setTimeout('startBot()',settimeout*1000);
}

//开始建筑
function zao(str){
			var arr = str.split(",");
		    var  id = arr[0];
		    var vid = arr[1];
			var bid = arr[2];
			var nono = arr[4];
			//nono2是最低库存的田种已超过 设定目标等级，所以删除任务
			if(nono == 'nono2'){
			    $.get("{:url('set_task')}/vid/"+vid+'/uid/'+uid+'/id/'+id+'/inctime/123456/nono/'+nono,function(data){
				});
				$("[data-tid='"+id+"']").remove();
			}else{
			$.get(server +"build.php?id="+bid+"&newdid="+vid+'&m='+Math.random(),function(build){
				//如果是最高等级建筑，则直接删除任务
				if($(build).find('span.none').text() == 'The building is at the maximum level.'){
					var nono = 'nono2';
					$.get("{:url('set_task')}/vid/"+vid+'/uid/'+uid+'/id/'+id+'/inctime/123456/nono/'+nono,function(data){
				    });
					$("[data-tid='"+id+"']").remove();
				}else{
				if($(build).find('.small').length>0){
			    var click_url = $(build).find('.small').attr('onclick');
			    var arr = click_url.split("'");
				var links = arr[1];
				$.get(server+links+"&newdid="+vid,function(build2){
				    if($(build2).find('.buildDuration #timer1').length>0){
					    var timess = $(build2).find('.buildDuration #timer1').text();
						var timeba = timeb(timess);
						$.get("{:url('set_task')}/vid/"+vid+'/uid/'+uid+'/id/'+id+'/inctime/'+timeba+'/nono/'+nono,function(data){
						    if(data == 'ok'){
							    //更新任务成功
								if(nono != 'nono'){$("[data-tid='"+id+"']").remove();}
								read_viliage();
							}else{
								//alert('更新失败');
							}
						});
					}else{
					    //alert('建造失败');
					}
				});
				}else{
				    //alert('不能建造');
				}
				}
			    
			});
			}
			
		//sleep_a();
}

/*
$('#read_task1').click(function(){
$('#task_grid').html('');
    var account = $("[name='account']").val();
    $.get("{:url('get_viliage')}/account/"+account,function(data){
	    var vtitle = '';
	    var viliage = '';var vcontent = '';var ii=0;kk=0;
		vtitle   += '<ul class="uk-subnav uk-subnav-pill" data-uk-switcher="{connect:\'#subnav-pill-content-1\'}">';
		vcontent += '<ul id="subnav-pill-content-1" class="uk-switcher">';
		$.each(data,function(i,n){
		    var task = '';var vhtml2 = '';ii++;
			if(ii==1){vtitle   += '<li class=""><a href="#">'+n['vid']+'</a></li>';}else{vtitle   += '<li aria-expanded="false" class=""><a href="#">'+n['vid']+'</a></li>';}
			vcontent += '<li>aaaaaaa'+ii;
		    $.get("{:url('get_task')}/vid/"+n['vid'],'',function(data2){
	            $.each(data2,function(i2,n2){
	                //task += n2['build'];
	                //task += '<br>';
					task +='<button class="uk-button uk-button-primary" type="button" onclick=\'addtask('+n['vid']+'|'+n2['build']+')\'>'+n2['title']+'/'+n2['level']+'</button><br>';
	            });*/
		    /*
			viliage += '<div class="uk-width-1-6">';
			viliage += n['vid']+' ：'+n['date']+'<br>';
			viliage += task;
			viliage += '</div>';
			$('#task_grid').append(viliage);
			*/
			/*
	        });
			vcontent += task;
			vcontent += '</li>';
		});
		vtitle   += '</ul>';
		vcontent += '</ul>';
		$('#task_grid').html(vtitle);
		$('#task_grid').append(vcontent);
	});
});
*/
function ajax(url,type){
    $.ajax({
		url: url,
		type: 'get',
		cache:false, 
		//data: obj,
		dataType: type,
		success: function(data) {
		    return data;
	    }
	 });
}

function go1(){ //检测所有村庄，下一次建筑时间是否到。
	var account = $("[name='account']").val();
	var server = $("[name='account']").find("option:selected").attr('data-server');
	$.get("{:url('get_viliage')}/account/"+account,'',function(data){
	    var viliage = '';var start_build_time;
		$.each(data,function(i,n){
		    start_build_time = n['start_build_time'];
		    var task = '';$i2 = 0;
		    $.get("{:url('get_taskfirst')}/vid/"+n['vid'],'',function(data2){
				if(data2.build){
				    var build = data2.build;
					//console.log(data);  
					if(n['start'] == 'ok'){
					    var drof = server+'/build.php?id='+data2.build;
					    /*
						var rs = ajax(drof,'html');
						alert(rs);
						*/
						$.ajax({
							url: drof,
							type: 'get',
							cache:false, 
							dataType: 'html',
							success: function(rs) {
								var click_url = $(rs).find('.small').attr('onclick');
								if(typeof(click_url)!="undefined"){
								var arr = click_url.split('\'');
								    //可建造
									var str;
									str = n['vid']+'|';//村庄数据库ID
									str += arr[1]+'|';//建筑升级链接
									str +=  data2.id;//建筑数据库ID
									setTimeout('go2("'+str+'")',3230);
									return false;
								}else{
								    //不能建造
									
								}
							}
						});
					}
				}
	        });
		});
		
	});
}

function go2(str){
/*
console.log(arg);
return;
alert(arg[0]+'-1');alert(arg[1]+'-2');alert(arg[2]+'-3');*/
var arg = str.split('|');

     var server = $("[name='account']").find("option:selected").attr('data-server');
	 alert(server+'/'+arg[1]);
	 var uid = $("[name='account']").val();
     $.get(server+'/'+arg[1],function(data){
	     var time = $(data).find('span[id^="time"]').html();
		 var s = time_to_s(time);
		 $.get("{:url('set_build_time')}/uid/"+uid+"/vid/"+arg[0]+"/time/"+s+"/bid/"+arg[2],function(data){
		 var aa;
		 });
	 });
}

function time_to_s(time){
    var arr = time.split(':');
	var s = arr[0]*60*60 + arr[1]*60 + arr[2];
    return s
}

$('#stop_task').click(function(){
    window.clearInterval(t1);
});

$('#test1').click(function(){
    /*
	var arr_num = [];var num;
    $('body').find('.stockBarButton .value').each(function(){
    num = $(this).text()*1;
    arr_num.push(num);
	
	});
	alert(arr_num.indexOf(Math.min.apply(Math, arr_num)));
	*/
	
	var resource = [];
	var href;
	resource[0] = "<div style='color:\\#FFF'><b>Bosque</b>";
	resource[1] = "<div style='color:\\#FFF'><b>Poço de Barro</b>";
	resource[2] = "<div style='color:\\#FFF'><b>Mina de Ferro</b>";
	resource[3] = "<div style='color:\\#FFF'><b>Campo de Cereal</b>";
	var arr_num = [];var num;
	$('.stockBarButton .value').each(function(){
	    num = $(this).text()*1;
	    arr_num.push(num);
		//alert(num);
	});
	var n = resource[arr_num.indexOf(Math.min.apply(Math, arr_num))];
	//alert(n);
	//alert($('map area[title*="'+n+'"]').length);
	var arr_num2 = [];
	$('map area[title*="'+n+'"]').each(function(){
		var str = $(this).attr('title');
		var n11=str.indexOf("</b> nível ")+11;　
		var n12=str.indexOf("</div>");　
		var num2 = str.substring(n11,n12)*1;
		arr_num2.push(num2);
	});
	if(Math.min.apply(Math, arr_num2)<15){
		//如果最小的指定类型田大于等于设定目标等级，则跳过，并删除任务
	    var n2 = arr_num2.indexOf(Math.min.apply(Math, arr_num2));
		href = $('map area[title*="'+n+'"]:eq('+n2+')').attr('href');
	}
});
</script>
</html>